//
//  SLPagerHelper.h
//  SLPagerView
//
//  Created by l.t.zero on 2022/1/7.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT void sl_dispatch_main_sync_safe(dispatch_block_t block);
FOUNDATION_EXPORT void sl_protectResignFirstResponderIn(UIView *view, dispatch_block_t block);

typedef id __nonnull (^sl_map_block)(id obj);
typedef BOOL (^sl_filter_block)(id obj);

FOUNDATION_EXPORT NSArray *sl_array_map(NSArray *array, sl_map_block block);
FOUNDATION_EXPORT NSArray *sl_array_filter(NSArray *array, sl_filter_block block);

@interface SLPagerObject : NSObject

@property (nonatomic, weak) id view;
@property (nonatomic) NSIndexPath *indexPath;
@property (nonatomic, strong) id item;
@property (nonatomic, assign) BOOL scrolling;

- (NSInteger)index;

@end

typedef Class __nonnull (^sl_pager_add_block)(id target);
FOUNDATION_EXPORT void sl_pager_item_add_cell_for_class(id obj, sl_pager_add_block block);

FOUNDATION_EXPORT SLPagerObject *pagerObjectFrom(id view, NSIndexPath *indexPath, id item);

NS_ASSUME_NONNULL_END
